//
//  InessViewCell.m
//  KMedicine
//
//  Created by 452608533 on 16/7/7.
//  Copyright © 2016年 caomu. All rights reserved.
//

#import "InessViewCell.h"

@interface InessViewCell()

@end

@implementation InessViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    
    UIButton *cellButton = [[UIButton alloc] init];
    
    self.button = cellButton;
    
    [cellButton addTarget:self action:@selector(didButton:) forControlEvents:UIControlEventTouchUpInside];
    
    [cellButton setTitle:@"订阅" forState:UIControlStateNormal];
    
    [cellButton setTitle:@"已订阅" forState:UIControlStateSelected];
    
    [cellButton setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
    
    cellButton.layer.cornerRadius = 5;
    
    [cellButton setBackgroundColor:kThemeColor];
    
    [self addSubview:cellButton];
    
    [cellButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.offset(5);
        make.trailing.offset(-20);
        make.bottom.offset(-5);
        make.width.equalTo(80);
        
    }];
}

- (void)didButton:(UIButton *)sender {
    
    // 改变 button 的 选中状态
    sender.selected = !sender.isSelected;
    
    //判断代理
    if ([self.inessDelegate respondsToSelector:@selector(currentCell:buttonStatus:)]) {
        [self.inessDelegate currentCell:self buttonStatus:sender.isSelected];
    }
    

}
 

@end
